package com.code.mapper;


import com.code.bean.Employee;
import org.apache.ibatis.annotations.*;

import java.util.Collection;
import java.util.List;

//@Mapper或者@MapperScan将接口扫描装配到容器中
public interface EmployeeMapper {

    @Select("select * from employee where id=#{id}")
    public Employee get(Integer id);

    @Options(useGeneratedKeys = true,keyProperty = "id")
    @Insert("insert into employee(lastName,email,gender,d_id) values(#{lastName},#{email},#{gender},#{dId})")
    public void save(Employee employee);

    @Select("select * from employee")
    public List<Employee> getAll();

    @Delete("delete from employee where id=#{id}")
    public void delete(Integer id);

    @Update("UPDATE employee SET lastName=#{lastName},email=#{email},gender=#{gender},d_id=#{dId} WHERE id=#{id}")
    public void updateEmp(Employee employee);

    @Select("SELECT * FROM employee WHERE lastName = #{lastName}")
    Employee getEmpByLastName(String lastName);

}
